﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WF_Loadout_Editor
{
    public struct Part
    {
        private float normal;
        public float Normal
        {
            get { return normal; }
            set { normal = value; }
        }

        private float armorPen;
        public float ArmorPen
        {
            get { return armorPen; }
            set { armorPen = value; }
        }

        private float electric;
        public float Electric
        {
            get { return electric; }
            set { electric = value; }
        }

        private float fire;
        public float Fire
        {
            get { return fire; }
            set { fire = value; }
        }

        private float frost;
        public float Frost
        {
            get { return frost; }
            set { frost = value; }
        }

        private float baseNormal;
        public float BaseNormal
        {
            get { return baseNormal; }
            set { baseNormal = value; }
        }

        private float baseArmorPen;
        public float BaseArmorPen
        {
            get { return baseArmorPen; }
            set { baseArmorPen = value; }
        }

        private float baseElectric;
        public float BaseElectric
        {
            get { return baseElectric; }
            set { baseElectric = value; }
        }

        private float baseFire;
        public float BaseFire
        {
            get { return baseFire; }
            set { baseFire = value; }
        }

        private float baseFrost;
        public float BaseFrost
        {
            get { return baseFrost; }
            set { baseFrost = value; }
        }

        public Part(float normal1, float armorpen1, float electric1, float fire1, float frost1)
        {
            normal = baseNormal= normal1;
            armorPen = baseArmorPen = armorpen1;
            electric= baseElectric = electric1;
            fire = baseFire = fire1;
            frost = baseFrost = frost1;
        }

        public void UpdateStat(Object obj,bool isCrit)
        {
            Weapon weapon = (Weapon) obj;
            // new normal_dmg = (normal_dmg + (normal_dmg * normal_mod)) * enemy_normal_res
            if (isCrit)
            {

            }
            else
            {
                normal = weapon.Damage * (baseNormal / 100.0f);
                armorPen = (weapon.Damage * (weapon.ArmorPierceDamage / 100.0f)) * (baseArmorPen / 100.0f);
                electric = (weapon.Damage * (weapon.ElectricDamage / 100.0f)) * (baseElectric / 100.0f);
                fire = (weapon.Damage * (weapon.FireDamage / 100.0f)) * (baseFire / 100.0f);
                frost = (weapon.Damage * (weapon.FreezeDamage / 100.0f)) * (baseFrost / 100.0f);
            }
        }
    }

    public class Enemy
    {
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private List<Part> parts;
        public List<Part> Parts
        {
            get { return parts; }
            set { parts = value; }
        }

        public Enemy()
        {
        }

        public Enemy(string name1, List<Part> parts1)
        {
            name = name1;
            parts = new List<Part>(parts1);
        }

        public void UpdateStats(Object obj, bool isCrit)
        {
            for (int i = 0; i < parts.Count; ++i)
                parts[i].UpdateStat(obj, isCrit);
        }
    }

    public class Faction
    {
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private List<Enemy> enemies;
        public List<Enemy> Enemies
        {
            get { return enemies; }
            set { enemies = value; }
        }

        public Faction()
        {
        }

        public Faction(string name1, List<Enemy> enemies1)
        {
            name = name1;
            enemies = new List<Enemy>(enemies1);
        }
    }
}
